<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" href="/css/layui.css">
</head>
 <body>
  <div style="width: 800px;margin: 0 auto;position: absolute;left: 5%;">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 50px;text-align: center">
        <legend>添加试卷信息</legend>
    </fieldset>

      <form class="layui-form"  lay-filter="addTest">
          <div class="layui-form-item">
              <label class="layui-form-label">考试名称</label>
              <div class="layui-input-inline">
                  <input type="text" name="testName" lay-verify="title" autocomplete="off" placeholder="请输入名称" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">考试时间</label>
              <div class="layui-input-inline">
                  <input type="text" name="testTime" placeholder="" autocomplete="off" class="layui-input">
              </div>
          </div>
          <div class="layui-form-item">
              <label class="layui-form-label">出题人</label>
              <div class="layui-input-inline">
                  <input type="text" name="testAuthor" lay-verify="required" lay-reqText="请输入出题人" placeholder="请输入出题人" autocomplete="off" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label">试题难度</label>
              <div class="layui-input-inline">
                  <input type="text" name="difficulty" lay-verify="required" lay-reqText="请输入难度系数" placeholder="请输入难度系数" autocomplete="off" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item">
              <label class="layui-form-label">备注</label>
              <div class="layui-input-inline">
                  <input type="text" name="link" lay-verify="required" lay-reqText="" placeholder="" autocomplete="off" class="layui-input">
              </div>
          </div>

          <div class="layui-form-item" style="text-align: center">
              <button  class="layui-btn" lay-submit lay-filter="doSubmit">新增</button>
              <input type="reset" class="layui-btn" >重置</input>
          </div>

      </form>
  </div>
 </body>
<script src="/layui.js"></script>
<script src="/js/jquery-1.8.3.js"></script>
<script>
    layui.use(["form","layer"],function () {
        let form=layui.form;
        let layer=layui.layer;

        form.on("submit(doSubmit)",function (data) {
            $.post("/test/addTestInfo",data.field,function (res) {
                if (res.success=="true"){
                    layer.alert("新增成功！",{icon:6,time:2000});
                    setTimeout(function () {
                        layer.closeAll();
                    }, 1000*1.5)
                } else {
                    layer.alert(res.msg,{icon:5,time:2000})
                }

            });
            return false;
        })

    })
</script>
</html>